\(\int f^{a+c x^2} \cos ^2(d+e x+f x^2) \, dx\) [123]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [C] (verification not implemented)
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 23, antiderivative size = 211 \[ \int f^{a+c x^2} \cos ^2\left (d+e x+f x^2\right ) \, dx=\frac {f^a \sqrt {\pi } \text {erfi}\left (\sqrt {c} x \sqrt {\log (f)}\right )}{4 \sqrt {c} \sqrt {\log (f)}}+\frac {e^{-2 i d-\frac {e^2}{2 i f-c \log (f)}} f^a \sqrt {\pi } \text {erf}\left (\frac {i e+x (2 i f-c \log (f))}{\sqrt {2 i f-c \log (f)}}\right )}{8 \sqrt {2 i f-c \log (f)}}+\frac {e^{2 i d+\frac {e^2}{2 i f+c \log (f)}} f^a \sqrt {\pi } \text {erfi}\left (\frac {i e+x (2 i f+c \log (f))}{\sqrt {2 i f+c \log (f)}}\right )}{8 \sqrt {2 i f+c \log (f)}} \]

[Out]

1/4*f^a*erfi(x*c^(1/2)*ln(f)^(1/2))*Pi^(1/2)/c^(1/2)/ln(f)^(1/2)+1/8*exp(-2*I*d-e^2/(2*I*f-c*ln(f)))*f^a*erf((
I*e+x*(2*I*f-c*ln(f)))/(2*I*f-c*ln(f))^(1/2))*Pi^(1/2)/(2*I*f-c*ln(f))^(1/2)+1/8*exp(2*I*d+e^2/(2*I*f+c*ln(f))
)*f^a*erfi((I*e+x*(2*I*f+c*ln(f)))/(2*I*f+c*ln(f))^(1/2))*Pi^(1/2)/(2*I*f+c*ln(f))^(1/2)

Rubi [A] (verified)

Time = 0.41 (sec) , antiderivative size = 211, normalized size of antiderivative = 1.00, number of steps used = 9, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.217, Rules used = {4561, 2235, 2325, 2266, 2236} \[ \int f^{a+c x^2} \cos ^2\left (d+e x+f x^2\right ) \, dx=\frac {\sqrt {\pi } f^a e^{-\frac {e^2}{-c \log (f)+2 i f}-2 i d} \text {erf}\left (\frac {x (-c \log (f)+2 i f)+i e}{\sqrt {-c \log (f)+2 i f}}\right )}{8 \sqrt {-c \log (f)+2 i f}}+\frac {\sqrt {\pi } f^a e^{\frac {e^2}{c \log (f)+2 i f}+2 i d} \text {erfi}\left (\frac {x (c \log (f)+2 i f)+i e}{\sqrt {c \log (f)+2 i f}}\right )}{8 \sqrt {c \log (f)+2 i f}}+\frac {\sqrt {\pi } f^a \text {erfi}\left (\sqrt {c} x \sqrt {\log (f)}\right )}{4 \sqrt {c} \sqrt {\log (f)}} \]

[In]

Int[f^(a + c*x^2)*Cos[d + e*x + f*x^2]^2,x]

[Out]

(f^a*Sqrt[Pi]*Erfi[Sqrt[c]*x*Sqrt[Log[f]]])/(4*Sqrt[c]*Sqrt[Log[f]]) + (E^((-2*I)*d - e^2/((2*I)*f - c*Log[f])
)*f^a*Sqrt[Pi]*Erf[(I*e + x*((2*I)*f - c*Log[f]))/Sqrt[(2*I)*f - c*Log[f]]])/(8*Sqrt[(2*I)*f - c*Log[f]]) + (E
^((2*I)*d + e^2/((2*I)*f + c*Log[f]))*f^a*Sqrt[Pi]*Erfi[(I*e + x*((2*I)*f + c*Log[f]))/Sqrt[(2*I)*f + c*Log[f]
]])/(8*Sqrt[(2*I)*f + c*Log[f]])

Rule 2235

Int[(F_)^((a_.) + (b_.)*((c_.) + (d_.)*(x_))^2), x_Symbol] :> Simp[F^a*Sqrt[Pi]*(Erfi[(c + d*x)*Rt[b*Log[F], 2
]]/(2*d*Rt[b*Log[F], 2])), x] /; FreeQ[{F, a, b, c, d}, x] && PosQ[b]

Rule 2236

Int[(F_)^((a_.) + (b_.)*((c_.) + (d_.)*(x_))^2), x_Symbol] :> Simp[F^a*Sqrt[Pi]*(Erf[(c + d*x)*Rt[(-b)*Log[F],
 2]]/(2*d*Rt[(-b)*Log[F], 2])), x] /; FreeQ[{F, a, b, c, d}, x] && NegQ[b]

Rule 2266

Int[(F_)^((a_.) + (b_.)*(x_) + (c_.)*(x_)^2), x_Symbol] :> Dist[F^(a - b^2/(4*c)), Int[F^((b + 2*c*x)^2/(4*c))
, x], x] /; FreeQ[{F, a, b, c}, x]

Rule 2325

Int[(u_.)*(F_)^(v_)*(G_)^(w_), x_Symbol] :> With[{z = v*Log[F] + w*Log[G]}, Int[u*NormalizeIntegrand[E^z, x],
x] /; BinomialQ[z, x] || (PolynomialQ[z, x] && LeQ[Exponent[z, x], 2])] /; FreeQ[{F, G}, x]

Rule 4561

Int[Cos[v_]^(n_.)*(F_)^(u_), x_Symbol] :> Int[ExpandTrigToExp[F^u, Cos[v]^n, x], x] /; FreeQ[F, x] && (LinearQ
[u, x] || PolyQ[u, x, 2]) && (LinearQ[v, x] || PolyQ[v, x, 2]) && IGtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \int \left (\frac {1}{2} f^{a+c x^2}+\frac {1}{4} e^{-2 i d-2 i e x-2 i f x^2} f^{a+c x^2}+\frac {1}{4} e^{2 i d+2 i e x+2 i f x^2} f^{a+c x^2}\right ) \, dx \\ & = \frac {1}{4} \int e^{-2 i d-2 i e x-2 i f x^2} f^{a+c x^2} \, dx+\frac {1}{4} \int e^{2 i d+2 i e x+2 i f x^2} f^{a+c x^2} \, dx+\frac {1}{2} \int f^{a+c x^2} \, dx \\ & = \frac {f^a \sqrt {\pi } \text {erfi}\left (\sqrt {c} x \sqrt {\log (f)}\right )}{4 \sqrt {c} \sqrt {\log (f)}}+\frac {1}{4} \int \exp \left (-2 i d-2 i e x+a \log (f)-x^2 (2 i f-c \log (f))\right ) \, dx+\frac {1}{4} \int \exp \left (2 i d+2 i e x+a \log (f)+x^2 (2 i f+c \log (f))\right ) \, dx \\ & = \frac {f^a \sqrt {\pi } \text {erfi}\left (\sqrt {c} x \sqrt {\log (f)}\right )}{4 \sqrt {c} \sqrt {\log (f)}}+\frac {1}{4} \left (e^{-2 i d-\frac {e^2}{2 i f-c \log (f)}} f^a\right ) \int \exp \left (\frac {(-2 i e+2 x (-2 i f+c \log (f)))^2}{4 (-2 i f+c \log (f))}\right ) \, dx+\frac {1}{4} \left (e^{2 i d+\frac {e^2}{2 i f+c \log (f)}} f^a\right ) \int \exp \left (\frac {(2 i e+2 x (2 i f+c \log (f)))^2}{4 (2 i f+c \log (f))}\right ) \, dx \\ & = \frac {f^a \sqrt {\pi } \text {erfi}\left (\sqrt {c} x \sqrt {\log (f)}\right )}{4 \sqrt {c} \sqrt {\log (f)}}+\frac {e^{-2 i d-\frac {e^2}{2 i f-c \log (f)}} f^a \sqrt {\pi } \text {erf}\left (\frac {i e+x (2 i f-c \log (f))}{\sqrt {2 i f-c \log (f)}}\right )}{8 \sqrt {2 i f-c \log (f)}}+\frac {e^{2 i d+\frac {e^2}{2 i f+c \log (f)}} f^a \sqrt {\pi } \text {erfi}\left (\frac {i e+x (2 i f+c \log (f))}{\sqrt {2 i f+c \log (f)}}\right )}{8 \sqrt {2 i f+c \log (f)}} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.67 (sec) , antiderivative size = 252, normalized size of antiderivative = 1.19 \[ \int f^{a+c x^2} \cos ^2\left (d+e x+f x^2\right ) \, dx=\frac {1}{8} f^a \sqrt {\pi } \left (\frac {2 \text {erfi}\left (\sqrt {c} x \sqrt {\log (f)}\right )}{\sqrt {c} \sqrt {\log (f)}}+\frac {\sqrt [4]{-1} \left (-e^{\frac {e^2}{-2 i f+c \log (f)}} \text {erfi}\left (\frac {(-1)^{3/4} (e+2 f x+i c x \log (f))}{\sqrt {2 f+i c \log (f)}}\right ) (2 f-i c \log (f)) \sqrt {2 f+i c \log (f)} (\cos (2 d)-i \sin (2 d))+e^{\frac {e^2}{2 i f+c \log (f)}} \text {erfi}\left (\frac {\sqrt [4]{-1} (e+2 f x-i c x \log (f))}{\sqrt {2 f-i c \log (f)}}\right ) \sqrt {2 f-i c \log (f)} (2 f+i c \log (f)) (-i \cos (2 d)+\sin (2 d))\right )}{4 f^2+c^2 \log ^2(f)}\right ) \]

[In]

Integrate[f^(a + c*x^2)*Cos[d + e*x + f*x^2]^2,x]

[Out]

(f^a*Sqrt[Pi]*((2*Erfi[Sqrt[c]*x*Sqrt[Log[f]]])/(Sqrt[c]*Sqrt[Log[f]]) + ((-1)^(1/4)*(-(E^(e^2/((-2*I)*f + c*L
og[f]))*Erfi[((-1)^(3/4)*(e + 2*f*x + I*c*x*Log[f]))/Sqrt[2*f + I*c*Log[f]]]*(2*f - I*c*Log[f])*Sqrt[2*f + I*c
*Log[f]]*(Cos[2*d] - I*Sin[2*d])) + E^(e^2/((2*I)*f + c*Log[f]))*Erfi[((-1)^(1/4)*(e + 2*f*x - I*c*x*Log[f]))/
Sqrt[2*f - I*c*Log[f]]]*Sqrt[2*f - I*c*Log[f]]*(2*f + I*c*Log[f])*((-I)*Cos[2*d] + Sin[2*d])))/(4*f^2 + c^2*Lo
g[f]^2)))/8

Maple [A] (verified)

Time = 0.82 (sec) , antiderivative size = 191, normalized size of antiderivative = 0.91

method result size
risch \(\frac {\sqrt {\pi }\, f^{a} {\mathrm e}^{-\frac {2 i d \ln \left (f \right ) c +4 d f -e^{2}}{c \ln \left (f \right )-2 i f}} \operatorname {erf}\left (x \sqrt {2 i f -c \ln \left (f \right )}+\frac {i e}{\sqrt {2 i f -c \ln \left (f \right )}}\right )}{8 \sqrt {2 i f -c \ln \left (f \right )}}-\frac {\sqrt {\pi }\, f^{a} {\mathrm e}^{\frac {2 i d \ln \left (f \right ) c -4 d f +e^{2}}{2 i f +c \ln \left (f \right )}} \operatorname {erf}\left (-\sqrt {-c \ln \left (f \right )-2 i f}\, x +\frac {i e}{\sqrt {-c \ln \left (f \right )-2 i f}}\right )}{8 \sqrt {-c \ln \left (f \right )-2 i f}}+\frac {f^{a} \sqrt {\pi }\, \operatorname {erf}\left (\sqrt {-c \ln \left (f \right )}\, x \right )}{4 \sqrt {-c \ln \left (f \right )}}\) \(191\)

[In]

int(f^(c*x^2+a)*cos(f*x^2+e*x+d)^2,x,method=_RETURNVERBOSE)

[Out]

1/8*Pi^(1/2)*f^a*exp(-(2*I*d*ln(f)*c+4*d*f-e^2)/(c*ln(f)-2*I*f))/(2*I*f-c*ln(f))^(1/2)*erf(x*(2*I*f-c*ln(f))^(
1/2)+I*e/(2*I*f-c*ln(f))^(1/2))-1/8*Pi^(1/2)*f^a*exp((2*I*d*ln(f)*c-4*d*f+e^2)/(2*I*f+c*ln(f)))/(-c*ln(f)-2*I*
f)^(1/2)*erf(-(-c*ln(f)-2*I*f)^(1/2)*x+I*e/(-c*ln(f)-2*I*f)^(1/2))+1/4*f^a*Pi^(1/2)/(-c*ln(f))^(1/2)*erf((-c*l
n(f))^(1/2)*x)

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 361 vs. \(2 (155) = 310\).

Time = 0.27 (sec) , antiderivative size = 361, normalized size of antiderivative = 1.71 \[ \int f^{a+c x^2} \cos ^2\left (d+e x+f x^2\right ) \, dx=-\frac {2 \, \sqrt {\pi } {\left (c^{2} \log \left (f\right )^{2} + 4 \, f^{2}\right )} \sqrt {-c \log \left (f\right )} f^{a} \operatorname {erf}\left (\sqrt {-c \log \left (f\right )} x\right ) + \sqrt {\pi } {\left (c^{2} \log \left (f\right )^{2} - 2 i \, c f \log \left (f\right )\right )} \sqrt {-c \log \left (f\right ) - 2 i \, f} \operatorname {erf}\left (\frac {{\left (c^{2} x \log \left (f\right )^{2} + 4 \, f^{2} x + i \, c e \log \left (f\right ) + 2 \, e f\right )} \sqrt {-c \log \left (f\right ) - 2 i \, f}}{c^{2} \log \left (f\right )^{2} + 4 \, f^{2}}\right ) e^{\left (\frac {a c^{2} \log \left (f\right )^{3} + 2 i \, c^{2} d \log \left (f\right )^{2} - 2 i \, e^{2} f + 8 i \, d f^{2} + {\left (c e^{2} + 4 \, a f^{2}\right )} \log \left (f\right )}{c^{2} \log \left (f\right )^{2} + 4 \, f^{2}}\right )} + \sqrt {\pi } {\left (c^{2} \log \left (f\right )^{2} + 2 i \, c f \log \left (f\right )\right )} \sqrt {-c \log \left (f\right ) + 2 i \, f} \operatorname {erf}\left (\frac {{\left (c^{2} x \log \left (f\right )^{2} + 4 \, f^{2} x - i \, c e \log \left (f\right ) + 2 \, e f\right )} \sqrt {-c \log \left (f\right ) + 2 i \, f}}{c^{2} \log \left (f\right )^{2} + 4 \, f^{2}}\right ) e^{\left (\frac {a c^{2} \log \left (f\right )^{3} - 2 i \, c^{2} d \log \left (f\right )^{2} + 2 i \, e^{2} f - 8 i \, d f^{2} + {\left (c e^{2} + 4 \, a f^{2}\right )} \log \left (f\right )}{c^{2} \log \left (f\right )^{2} + 4 \, f^{2}}\right )}}{8 \, {\left (c^{3} \log \left (f\right )^{3} + 4 \, c f^{2} \log \left (f\right )\right )}} \]

[In]

integrate(f^(c*x^2+a)*cos(f*x^2+e*x+d)^2,x, algorithm="fricas")

[Out]

-1/8*(2*sqrt(pi)*(c^2*log(f)^2 + 4*f^2)*sqrt(-c*log(f))*f^a*erf(sqrt(-c*log(f))*x) + sqrt(pi)*(c^2*log(f)^2 -
2*I*c*f*log(f))*sqrt(-c*log(f) - 2*I*f)*erf((c^2*x*log(f)^2 + 4*f^2*x + I*c*e*log(f) + 2*e*f)*sqrt(-c*log(f) -
 2*I*f)/(c^2*log(f)^2 + 4*f^2))*e^((a*c^2*log(f)^3 + 2*I*c^2*d*log(f)^2 - 2*I*e^2*f + 8*I*d*f^2 + (c*e^2 + 4*a
*f^2)*log(f))/(c^2*log(f)^2 + 4*f^2)) + sqrt(pi)*(c^2*log(f)^2 + 2*I*c*f*log(f))*sqrt(-c*log(f) + 2*I*f)*erf((
c^2*x*log(f)^2 + 4*f^2*x - I*c*e*log(f) + 2*e*f)*sqrt(-c*log(f) + 2*I*f)/(c^2*log(f)^2 + 4*f^2))*e^((a*c^2*log
(f)^3 - 2*I*c^2*d*log(f)^2 + 2*I*e^2*f - 8*I*d*f^2 + (c*e^2 + 4*a*f^2)*log(f))/(c^2*log(f)^2 + 4*f^2)))/(c^3*l
og(f)^3 + 4*c*f^2*log(f))

Sympy [F]

\[ \int f^{a+c x^2} \cos ^2\left (d+e x+f x^2\right ) \, dx=\int f^{a + c x^{2}} \cos ^{2}{\left (d + e x + f x^{2} \right )}\, dx \]

[In]

integrate(f**(c*x**2+a)*cos(f*x**2+e*x+d)**2,x)

[Out]

Integral(f**(a + c*x**2)*cos(d + e*x + f*x**2)**2, x)

Maxima [C] (verification not implemented)

Result contains higher order function than in optimal. Order 9 vs. order 4.

Time = 0.25 (sec) , antiderivative size = 863, normalized size of antiderivative = 4.09 \[ \int f^{a+c x^2} \cos ^2\left (d+e x+f x^2\right ) \, dx=\text {Too large to display} \]

[In]

integrate(f^(c*x^2+a)*cos(f*x^2+e*x+d)^2,x, algorithm="maxima")

[Out]

1/16*(sqrt(pi)*sqrt(2*c^2*log(f)^2 + 8*f^2)*((I*f^(c*e^2/(c^2*log(f)^2 + 4*f^2))*f^a*cos(2*(c^2*d*log(f)^2 - e
^2*f + 4*d*f^2)/(c^2*log(f)^2 + 4*f^2)) + f^(c*e^2/(c^2*log(f)^2 + 4*f^2))*f^a*sin(2*(c^2*d*log(f)^2 - e^2*f +
 4*d*f^2)/(c^2*log(f)^2 + 4*f^2)))*erf(((c*log(f) - 2*I*f)*x - I*e)/sqrt(-c*log(f) + 2*I*f)) + (-I*f^(c*e^2/(c
^2*log(f)^2 + 4*f^2))*f^a*cos(2*(c^2*d*log(f)^2 - e^2*f + 4*d*f^2)/(c^2*log(f)^2 + 4*f^2)) + f^(c*e^2/(c^2*log
(f)^2 + 4*f^2))*f^a*sin(2*(c^2*d*log(f)^2 - e^2*f + 4*d*f^2)/(c^2*log(f)^2 + 4*f^2)))*erf(((c*log(f) + 2*I*f)*
x + I*e)/sqrt(-c*log(f) - 2*I*f)))*sqrt(c*log(f) + sqrt(c^2*log(f)^2 + 4*f^2))*sqrt(-c*log(f)) - sqrt(pi)*sqrt
(2*c^2*log(f)^2 + 8*f^2)*((f^(c*e^2/(c^2*log(f)^2 + 4*f^2))*f^a*cos(2*(c^2*d*log(f)^2 - e^2*f + 4*d*f^2)/(c^2*
log(f)^2 + 4*f^2)) - I*f^(c*e^2/(c^2*log(f)^2 + 4*f^2))*f^a*sin(2*(c^2*d*log(f)^2 - e^2*f + 4*d*f^2)/(c^2*log(
f)^2 + 4*f^2)))*erf(((c*log(f) - 2*I*f)*x - I*e)/sqrt(-c*log(f) + 2*I*f)) + (f^(c*e^2/(c^2*log(f)^2 + 4*f^2))*
f^a*cos(2*(c^2*d*log(f)^2 - e^2*f + 4*d*f^2)/(c^2*log(f)^2 + 4*f^2)) + I*f^(c*e^2/(c^2*log(f)^2 + 4*f^2))*f^a*
sin(2*(c^2*d*log(f)^2 - e^2*f + 4*d*f^2)/(c^2*log(f)^2 + 4*f^2)))*erf(((c*log(f) + 2*I*f)*x + I*e)/sqrt(-c*log
(f) - 2*I*f)))*sqrt(-c*log(f) + sqrt(c^2*log(f)^2 + 4*f^2))*sqrt(-c*log(f)) + 2*sqrt(pi)*((c^2*f^a*log(f)^2 +
4*f^(a + 2))*erf(x*conjugate(sqrt(-c*log(f)))) + (c^2*f^a*log(f)^2 + 4*f^(a + 2))*erf(sqrt(-c*log(f))*x)))/((c
^2*log(f)^2 + 4*f^2)*sqrt(-c*log(f)))

Giac [F]

\[ \int f^{a+c x^2} \cos ^2\left (d+e x+f x^2\right ) \, dx=\int { f^{c x^{2} + a} \cos \left (f x^{2} + e x + d\right )^{2} \,d x } \]

[In]

integrate(f^(c*x^2+a)*cos(f*x^2+e*x+d)^2,x, algorithm="giac")

[Out]

integrate(f^(c*x^2 + a)*cos(f*x^2 + e*x + d)^2, x)

Mupad [F(-1)]

Timed out. \[ \int f^{a+c x^2} \cos ^2\left (d+e x+f x^2\right ) \, dx=\int f^{c\,x^2+a}\,{\cos \left (f\,x^2+e\,x+d\right )}^2 \,d x \]

[In]

int(f^(a + c*x^2)*cos(d + e*x + f*x^2)^2,x)

[Out]

int(f^(a + c*x^2)*cos(d + e*x + f*x^2)^2, x)